package com.mawujun.util;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class ProcessServlet implements ApplicationListener   {

	@Autowired
	private JdbcTemplate jdbcTemplate1;
	
	@Override
	public void onApplicationEvent(ApplicationEvent arg0) {
		//UA_excelToDb_IS这个表是用来判断，某个用户，的某个模块的数据是否导完了
		String sql="if not exists (select * from sysobjects where name = 'UA_excelToDb_IS' and xtype='U')" +
				" begin" +
				" create table UA_excelToDb_IS(" +
				" cUser_Name VARCHAR(20)  NOT  NULL ," +//用户名
				" DbName VARCHAR(40)  NOT  NULL," +//连接的数据库名称
				" model VARCHAR(50)  NOT  NULL," +//模块的名称，哪个模块导了
				" state int default 0," +
				" constraint PK_cUser_Name_DbName_model PRIMARY KEY CLUSTERED(cUser_Name,DbName,model)" +
				")" +//状态 0，表示要导入，1正在导入，2导入完成，要是没有记录表示要导入和0的状态一样
				" end ";
		jdbcTemplate1.execute(sql);
	}


	

}
